package com.example.iot.util;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : Lin
 * @version : [v1.0]
 * @className : Gettoken
 * @description : 描述说明该类的功能
 * @createTime : 2023/7/2 16:31
 * @updateUser : Lin
 * @updateTime : 2023/7/2 16:31
 * @updateRemark : 描述说明本次修改内容
 */
public class Gettoken {
    static public Map GerRequestbody(String name,String iamname,String pwd){
        // 创建一个代表JSON对象的Java对象
        Map<String, Object> jsonMap = new HashMap<>();
        Map<String, Object> authMap = new HashMap<>();
        Map<String, Object> identityMap = new HashMap<>();
        List<String> methodsList = new ArrayList<>();
        Map<String, Object> passwordMap = new HashMap<>();
        Map<String, Object> userMap = new HashMap<>();
        Map<String, Object> domainMap = new HashMap<>();

// 设置JSON对象的属性值
        methodsList.add("password");
        domainMap.put("name", name);
        userMap.put("name", iamname);
        userMap.put("password", pwd );
        userMap.put("domain", domainMap);
        passwordMap.put("user", userMap);
        identityMap.put("methods", methodsList);
        identityMap.put("password", passwordMap);
        authMap.put("identity", identityMap);
        jsonMap.put("auth", authMap);



        String jsonString = JSON.toJSONString(jsonMap);


        return jsonMap;
    }
}
